package descentFly.app.dialogs.levelsWindow
{
	import UIFree.controls.base.uif_previewSource;
	import UIFree.uif_component;
	
	import descentFly.app.df_block;
	import descentFly.app.df_component;
	import descentFly.server.df_servers;
	
	import flash.geom.Rectangle;
	
	public class df_listItemImage extends df_block {
		private var _layer		: df_block;
		private var _preview	: df_previewSource;
		public function df_listItemImage(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, item: Object=null, a_styleClass:Object='block') {
			super(parent, ax, ay, awidth, aheight, a_styleClass);
			_data = item;
			_preview.loadSource(previewURL);
		}
		
		override protected function disableVisualization(): void {
			if (!disable) alpha = 1
			else alpha = 0.5;
		}
		
		override protected function createComponentLayer(inner:Rectangle): df_component {
			_layer = new df_block(this, inner.x, inner.y, inner.width, inner.height, style.layer);
			return _layer;
		}
		
		override protected function createComponents(layer: df_component, inner:Rectangle): void {
			super.createComponents(layer, inner);
			var inner: Rectangle = previewRect;
			_preview	= new df_previewSource(layer, inner.x, inner.y, inner.width, inner.height, style.image);
		}
		
		protected function get previewRect(): Rectangle {
			var inner: Rectangle = layer.getInner();
			inner.width = inner.height;
			return inner;
		}
		
		protected function get previewURL(): String {
			return '';
		}
		
		public function get layer(): df_block {
			return _layer;
		}
	}
}